<template>
    <main role="main">
        <!-- 按钮触发消息提示弹窗 -->
        <button id="alert-button" v-show="false" type="button" class="btn btn-primary" data-toggle="modal" data-target=".alert-modal-sm">提示框</button>
        <div class="modal fade alert-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                        <h4 class="modal-title">消息提示</h4>
                    </div>
                    <div class="modal-body">
                        {{msg}}
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                    </div>
                </div>
            </div>
        </div>

        <!-- 按钮触发确认弹窗 -->
        <button id="confirm-button" v-show="false" type="button" class="btn btn-primary" data-toggle="modal" data-target=".confirm-modal-sm">确认框</button>
        <div class="modal fade confirm-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                        <h4 class="modal-title">消息提示</h4>
                    </div>
                    <div class="modal-body">
                        {{msg}}
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" id="confirm-cancel-button" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" @click="confirmMethod">确定</button>
                    </div>
                </div>
            </div>
        </div>


    </main>
</template>


<script>

    export default {
        name: 'the-button',
        props: {
            msg: {
                default: ""
            },
            fun: {
                default: ""
            },
        },
        data: function () {
            return {
            }
        },
        mounted:function () {

        },
        methods: {
            confirmMethod(){
                let _this = this;
                $("#confirm-cancel-button").click();
                _this.$emit(_this.fun);
            }
        }
    }
</script>
